/**
 * 动作创建函数
 */

import { ADD_TASK, DEL_TASK } from "./actionTypes";

export const addTask = (text: string) => ({
  type: ADD_TASK,
  text,
});

export const delTask = (id: number) => ({
  type: DEL_TASK,
  id,
});

export const delTaskWithConfirm = (id: number) => {
  return (dispatch) => {
    if (window.confirm("你确认嘛")) {
      dispatch(delTask(id));
    }
  };
};
